<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:sec="http://www.springframework.org/security/tags"
      xmlns:p="http://primefaces.org/ui">

    <f:view locale="#{localeSwitcher.locale}">

        <h:head>
            <meta http-equiv="X-UA-Compatible" content="IE=edge" />
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <meta name="viewport"
                  content="width=device-width, initial-scale=1.0, user-scalable=no" />
            <h:outputScript library="primefaces" name="jquery/jquery.js" />

            <h:outputStylesheet name="css/base.css" />

            <title><ui:insert name="pageTitle"></ui:insert></title>
            <ui:insert name="head-extra" />
        </h:head>

        <h:body>
            <f:facet name="last">

            </f:facet>

            <div id="header" class="ui-header">

                <div class="ui-wrap-content"></div>

            </div>
            <!-- end header -->
            <div id="top"></div>
            <!-- contentDiv -->
            <div id="contentDiv">
                <div class="ui-wrap-content" style="height: 100%;">
                    <h:graphicImage value="#{resource['images:logo.png']}"
                                    class="header_logo" />
                    <div id="head">
                        <div id="headLangBox">

                            <div class="_50"
                                 style="padding-top: 25px; width: 200px; float: right;">
                                <h:form prependId="false">
                                    <h:panelGrid columns="8">
                                        <h:form id="selectLanguage">
                                            <sec:authorize ifAnyGranted="ROLE_ADMIN, ROLE_USER">
                                                <h:outputLabel for="user" value="#{out.hi}, " />
                                                <h:link id="user" value="#{request.userPrincipal.name}"
                                                        outcome="/pages/secure/profile.xhtml" />
                                            </sec:authorize>
                                            <p:commandLink action="#{localeSwitcher.changeLocal('hu')}"
                                                           onclick=" location.reload()" style="margin-left: 30px;">
                                                <h:graphicImage name="images/Hungary.png" />
                                            </p:commandLink>
                                            <p:commandLink action="#{localeSwitcher.changeLocal('en')}"
                                                           onclick=" location.reload()" style="margin-left: 5px;">
                                                <h:graphicImage name="images/England.png" />
                                            </p:commandLink>


                                        </h:form>
                                    </h:panelGrid>
                                </h:form>

                            </div>

                        </div>
                        <h2 style="padding-top: 0px;">
                            #{out.neuronBeer}
                            <ui:insert name="header"></ui:insert>
                        </h2>
                        <h:form>
                            <p:growl id="messages" />

                            <p:menubar>
                                <sec:authorize
                                    ifAnyGranted="ROLE_ADMIN,ROLE_LEADER">
                                    <p:submenu label="#{out.data}" icon="ui-icon-document">
                                        <p:menuitem value="#{out.recipes}"
                                                    actionListener="#{menuView.showRecipes}" />
                                        <p:menuitem value="#{out.materials}"
                                                    actionListener="#{menuView.showMaterials}" />
                                        <p:menuitem value="#{out.warehouses}"
                                                    actionListener="#{menuView.showWarehouses}" />
                                    </p:submenu>
                                </sec:authorize>
                                <sec:authorize ifAnyGranted="ROLE_ADMIN,ROLE_LEADER,ROLE_ORDERER">

                                    <p:menuitem value="#{out.orders_title}"
                                                actionListener="#{menuView.showOrders}" />

                                    <p:menuitem value="#{out.partners}"
                                                actionListener="#{menuView.showPartners}" />
                                </sec:authorize>
                                <sec:authorize ifAnyGranted="ROLE_ADMIN,ROLE_WORKER">

                                    <p:menuitem value="#{out.worker_title}"
                                                actionListener="#{menuView.showWorker}" />
                                </sec:authorize>
                                <sec:authorize ifAnyGranted="ROLE_ADMIN,ROLE_LEADER">


                                    <p:submenu label="#{out.leader}" icon="ui-icon-document">
                                        <p:menuitem value="Registry"
                                                    outcome="/pages/secure/leader_registry.xhtml" />
                                        <p:separator />
                                        <p:menuitem value="#{out.need_material_diagram}"
                                                    outcome="/pages/secure/leader_diagrams/material_needs.xhtml" />
                                        <p:menuitem value="#{out.need_beer_diagram}"
                                                    outcome="/pages/secure/leader_diagrams/beer_needs.xhtml" />
                                        <p:menuitem value="#{out.income_diagram}"
                                                    outcome="/pages/secure/leader_diagrams/income.xhtml" />
                                        <p:menuitem value="#{out.warehouse_diagram}"
                                                    outcome="/pages/secure/leader_diagrams/warehouse.xhtml" />
                                        <p:menuitem value="#{out.order_by_partner_diagram}"
                                                    outcome="/pages/secure/leader_diagrams/partner_income.xhtml" />
                                        <p:menuitem value="#{out.order_by_daily_income_diagram}"
                                                    outcome="/pages/secure/leader_diagrams/dailyIncome.xhtml" />
                                        <p:menuitem value="#{out.order_by_status_diagram}"
                                                    outcome="/pages/secure/leader_diagrams/status.xhtml" />
                                    </p:submenu>
                                </sec:authorize>
                                <sec:authorize ifAnyGranted="ROLE_ADMIN,ROLE_IMPORTER">

                                    <p:submenu label="#{out.importers}" icon="ui-icon-document">
                                        <p:menuitem value="#{out.upload_materials}"
                                                    outcome="/pages/secure/importer.xhtml" />
                                        <p:menuitem value="#{out.necessary_materials}"
                                                    outcome="/pages/secure/importer_necessary_materials.xhtml" />
                                    </p:submenu>
                                </sec:authorize>
                                <sec:authorize ifAnyGranted="ROLE_ADMIN,ROLE_EXPORTER">

                                    <p:menuitem value="#{out.exporter_title}"
                                                url="/pages/secure/exporter.xhtml" />
                                </sec:authorize>
                                <sec:authorize ifAnyGranted="ROLE_ADMIN">

                                    <p:menuitem value="#{out.admin_title}"
                                                url="/pages/secure/admin.xhtml" icon="ui-icon-unlocked" />
                                </sec:authorize>
                                <sec:authorize ifAnyGranted="ROLE_USER">
                                    <p:menuitem value="#{out.logout}"
                                                url="/j_spring_security_logout" icon="ui-icon-extlink" />
                                </sec:authorize>
                                <f:facet name="options">




                                </f:facet>
                                <sec:authorize ifAnyGranted="ROLE_ANONYMOUS">
                                    <p:menuitem value="#{out.login}" id="login"
                                                url="/pages/unsecure/login.xhtml" icon="ui-icon-unlocked" />
                                    <p:menuitem value="#{out.signup}"
                                                url="/pages/unsecure/signup.xhtml" icon="ui-icon-unlocked" />
                                </sec:authorize>

                            </p:menubar>

                        </h:form>
                    </div>
                    <p:separator />
                    <div id="content">
                        <div id="contentInside">
                            <ui:insert name="content" />
                        </div>
                    </div>

                </div>
            </div>
            <!-- end contentDiv -->

            <!-- footer -->

            <div id="footer" class="ui-footer">
                <h:outputText value="@Copyright 2014" />
            </div>

            <!-- end footer -->
        </h:body>

    </f:view>
</html>
